//520.检测大写字母
//https://leetcode.cn/problems/detect-capital
class Solution {
public:
    bool detectCapitalUse(string word) {
        int n = word.size();
        if(n == 1) return true;
        if (n >= 2 && word[0] >= 'a' && word[0] <= 'z' && word[1] >= 'A' && word[1] <= 'Z') return false;

        for(int i = 2;i<n;++i)
        {
            char ci = word[i],cie = word[i-1];

            if(
                (ci>='a' && ci<='z' && cie>='A' && cie<='Z')
                ||  
                (cie>='a' && cie<='z' && ci>='A' && ci<='Z')
              ) 
                return false;
        }
        return true;
    }
};